//
//  SMMacros.h
//  smzdm_lib
//
//  Created by tom on 16/6/5.
//  Copyright © 2016年 sm. All rights reserved.
//  代码人类进步的阶梯

#ifndef SMMacros_h
#define SMMacros_h

#define CreateMutableArray(var)   NSMutableArray *var = [NSMutableArray array]
#define CreateMutableDictionary(var)   NSMutableDictionary *var = [NSMutableDictionary dictionary]
#define CreateMutableAttributedStringWithString(var,str)    NSMutableAttributedString *var=[[NSMutableAttributedString alloc]initWithString:str]
#define CreateMutableAttributedStringWithAttributedString(var,attributedString)  NSMutableAttributedString *var=[[NSMutableAttributedString alloc] initWithAttributedString:attributedString]

#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)

#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)

#define MainAfter(t,block) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(t * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{    \
block  ;  \
});

#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

#define SMNotificationCenter [NSNotificationCenter defaultCenter]

#define SMAddObsver(methodName, noteName) [SMNotificationCenter addObserver:self selector:@selector(methodName) name:noteName object:nil];
#define SMRemoveObsver [SMNotificationCenter removeObserver:self];


#define iPhone4 ([UIScreen mainScreen].bounds.size.height == 480)
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)]?CGSizeEqualToSize(CGSizeMake(640, 1136),[[UIScreen mainScreen] currentMode].size):NO)
#define iPHONE6P [[UIScreen mainScreen] bounds].size.width == 414
#define iPHONE6 [[UIScreen mainScreen] bounds].size.width == 375
#define iOS6 [[[UIDevice currentDevice] systemVersion] doubleValue] >= 6.0
#define iOS7 [[[UIDevice currentDevice] systemVersion] doubleValue] >= 7.0
#define iOS8 [[[UIDevice currentDevice] systemVersion] doubleValue] >= 8.0
#define iOS9 [[[UIDevice currentDevice] systemVersion] doubleValue] >= 9.0
#define ScreenFrame [[UIScreen mainScreen] bounds]
#define DocumentDir [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]

#define Random (arc4random_uniform(255)+1)/255.0
#define RandomColor QDColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))
#define QDColorA(r, g, b, a)                    [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define QDClearColor [UIColor clearColor]
#define SMThemeColor  QDColorA(240,72,72,1)

#define strToImage(str) [UIImage imageNamed:str]
#define strToURL(str)  [NSURL URLWithString:str]
#define urlToRequest(a) [NSURLRequest requestWithURL:a]
#define fontSize(size)    [UIFont systemFontOfSize:size]


#ifdef DEBUG
#define SMLog(xx,...) NSLog(@"%s(line=%d): " xx, __func__, __LINE__, ##__VA_ARGS__)
#else
#define SMLog(xx,...)
#endif




#endif /* SMMacros_h */
